package com.dianrui.operation.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dianrui.operation.R;
import com.dianrui.operation.bean.Data;
;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class FeedBackAdapter extends BaseAdapter {
    private List<Data> list;
    private Context context;



    public FeedBackAdapter(Context context, List<Data> list) {
        this.list = list;
        this.context = context;

    }


    @Override
    public int getCount() {
        if (list == null) {
            return 0;
        }
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder viewHolder;
        if (convertView != null) {
            viewHolder = (ViewHolder) convertView.getTag();
        } else {
            convertView = LayoutInflater.from(context).inflate(R.layout.grid_item, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }
        if (list != null && list.size() > 0) {
            final Data item = list.get(position);
            viewHolder.feed_name.setText(item.getName());
            }
        return convertView;
    }



    class ViewHolder {
        @BindView(R.id.feed_name)
        TextView feed_name;


        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }

}
